$(function () {

    var error_bookname = false;
    var error_author = false;
    var error_publish=false;
    var error_bookcount=false;
    var error_check = false;


    $('#bookname').blur(function () {
        check_book_name();
    });
    $('#author').blur(function () {
        check_author();
    });
    $('#publish').blur(function () {
        check_publish();
    });
    $('#bookcount').blur(function () {
        check_bookcount();
    });



    function check_book_name() {
        var len = $('#bookname').val().length;
        if (len>=1) {
            $('#bookname').next().html('至少输入1字符的书名')
            $('#bookname').next().show();
            error_bookname = true;
        } else {
            $('#bookname').next().hide();
            error_bookname = false;
        }
    }
    function check_author() {
        var len = $('#author').val().length;
        if (len>=1) {
            $('#author').next().html('至少输入1字符的作者名字')
            $('#author').next().show();
            error_author = true;
        } else {
            $('#author').next().hide();
            error_author = false;
        }
    }
    function check_publish() {
        var len = $('#publish').val().length;
        if (len>=1) {
            $('#publish').next().html('至少输入1字符的出版社名字')
            $('#publish').next().show();
            error_publish = true;
        } else {
            $('#publish').next().hide();
            error_publish = false;
        }
    }

    function check_bookcount() {
        var len = $('#bookcount').val().length;
        if (len>=1) {
            $('#bookcount').next().html('不可为空')
            $('#bookcount').next().show();
            error_bookcount = true;
        } else {
            $('#bookcount').next().hide();
            error_bookcount = false;
        }
    }

    $('.reg_form').submit(function () {
        check_book_name();
         check_author();
         check_publish();
         check_bookcount();

        if (error_bookname == false && error_author == false && error_author == false&& error_bookcount==false && error_check==false) {
            return true;
        } else {
            return false;
        }

    });

})